﻿
using Catalog.API.Products.UpdateProduct;

namespace Catalog.API.Products.LockProduct
{
    public record LockProductResponse(bool IsOk ,Guid RecordId);
    public record LockProductRequest(Guid OrderId, Guid OrderName, Guid ProductId,Guid ProductName,decimal Qty);
    public class LockProductEndpoint : ICarterModule
    {
        public void AddRoutes(IEndpointRouteBuilder app)
        {
            app.MapPut("/lockProduct",
                async (LockProductRequest request, ISender sender) =>
                {
                    var command = request.Adapt<LockProductCommand>();

                    var result = await sender.Send(command);

                    var response = result.Adapt<LockProductResponse>();

                    return Results.Ok(response);
                })
                .WithName("lockProduct")
                .Produces<UpdateProductResponse>(StatusCodes.Status200OK)
                .ProducesProblem(StatusCodes.Status400BadRequest)
                .ProducesProblem(StatusCodes.Status404NotFound)
                .WithSummary("Lock Product")
                .WithDescription("Lock Product");
        }
    }
}
